package org.noote.shaky_remote;

public class RobotHelper {

	public static float getOne(int iData, int iDataMin, int iDataMid, int iDataMax)
	{
		return 0.5f+getMinusPlusOne(iData, iDataMin, iDataMid, iDataMax)/2.0f;
	}
	public static float getMinusPlusOne(int iData, int iDataMin, int iDataMid, int iDataMax)
	{
		float fRet = 0;
		
		if(iData>=iDataMax)
		{
			fRet = 1.0f;
		}
		else if(iData<=iDataMin)
		{
			fRet = 0.0f;
		}
		else if(iData>iDataMid)
		{
			float fDMax = iDataMax-iDataMid;
			float fD = iData-iDataMid;
			fRet = fD/fDMax;
		}
		else if(iData<iDataMid)
		{
			float fDMax = iDataMid-iDataMin;
			float fD = iDataMid-iData;
			fRet = ((fDMax-fD)/fDMax)-1.0f;
		}
		
		return fRet;
	}
}
